#include<bits/stdc++.h>
using namespace std;
struct awa{
	int w;//zhonglei
	int n;//weizhi
};
awa a[200010],b[200010];
int vis[200010];
int main(){
	freopen("fruit.in","r",stdin);
	freopen("fruit.out","w",stdout);
	int n;
	cin>>n;
	int i;
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i].w);
		a[i].n=i;
	}
	
	a[0].w=-1;
	b[0].w=-1;
	int fns=0;	
	int cnt=0;
	int nown=n;
	while(!fns)
	{
		cnt++;
		
		if(cnt%2==1)
		{
			for(i=1;i<=nown;i++)
			{
				if(a[i].w!=a[i-1].w)vis[i]=1;
			}
			int qwq=1;
			for(i=1;i<=nown;i++)
			{
				if(vis[i]&&a[i].n!=0)//printf("%d ",&a[i].n);
				cout<<a[i].n<<" ";
				else
				{
					b[qwq].w=a[i].w;
					b[qwq].n=a[i].n;
					qwq++;
				}
			}
			nown=qwq;
			cout<<endl;
			if(b[1].n==0)fns=1;
			memset(a,0,sizeof a);
			memset(vis,0,sizeof vis);
		}
		
		else 
		{
			for(i=1;i<=nown;i++)
			{
				if(b[i].w!=b[i-1].w)vis[i]=1;
			}
			int qwq=1;
			for(i=1;i<=nown;i++)
			{
				if(vis[i]&&b[i].n!=0)//printf("%d ",&b[i].n);
				cout<<b[i].n<<" ";
				else
				{
					a[qwq].w=b[i].w;
					a[qwq].n=b[i].n;
					qwq++;
				}
			}
			nown=qwq;
			cout<<endl;
			if(a[1].n==0)fns=1;
			memset(b,0,sizeof b);
			memset(vis,0,sizeof vis);
		}
		
		
		
	}
	
	
	
	
	
	
	
	return 0;
}
